import request from '@/utils/request'
import { API_CONFIG } from '@/api/config'

// 查询公告列表
export function listAnnouncement(query) {
  const params = {
    ...query,
    orgId: API_CONFIG.ORG_ID
  }
  return request({
    url: '/mobile/announcement/list',
    method: 'get',
    params: params
  })
}

// 查询公告详细
export function getAnnouncement(announcementId) {
  return request({
    url: '/mobile/announcement/' + announcementId,
    method: 'get',
    params: {
      orgId: API_CONFIG.ORG_ID
    }
  })
}

// 新增公告
export function addAnnouncement(data) {
  const requestData = {
    ...data,
    orgId: API_CONFIG.ORG_ID
  }
  return request({
    url: '/fun/announcement',
    method: 'post',
    data: requestData
  })
}

// 修改公告
export function updateAnnouncement(data) {
  const requestData = {
    ...data,
    orgId: API_CONFIG.ORG_ID
  }
  return request({
    url: '/fun/announcement',
    method: 'put',
    data: requestData
  })
}

// 删除公告
export function delAnnouncement(announcementId) {
  return request({
    url: '/fun/announcement/' + announcementId,
    method: 'delete',
    params: {
      orgId: API_CONFIG.ORG_ID
    }
  })
}